import httpUtils from "./XmlHttpTool";
var shopItem = cc.Class({
    name: 'shopItem',
    properties: {
       
        shopImageUrl:cc.String,
        shopName:cc.String,
        shopStatus:cc.Integer,
        chargeBtn:cc.Node,
        shopStar:cc.String
    }
});

cc.Class({
    extends: cc.Component,

    properties: {
       
        items: {
            default: [],
            type: shopItem
        },//代码几个item格子 初始化
        closeShopBtn:cc.Node,
        scrollShopScrollView:cc.Node,
        itemPrefab: cc.Prefab,//预制节点 代表cell内容详情
        markView:cc.Node
    },


    onLoad () {

        //    for (var i = 0; i < this.items.length; ++i) {

        //     var item = cc.instantiate(this.itemPrefab);
        //     this.node.addChild(item);
        //     item.getComponent('goodItems').init("1");

        // }

        this.markView.on('touchstart', function (event) {
            console.log("点击结算背景层")
          }, this);


        var that =this
        httpUtils.NhttpPost("/marmot/prize_list",{},function(res){

           that.items=res
           for (var i = 0; i < that.items.length; ++i) {

            var item = cc.instantiate(that.itemPrefab);
            that.node.addChild(item);
            item.getComponent('goodItems').init(that.items[i]);

        }
           
        },function(failres){

            console.log("星币商城请求错误",failres)
        })
       
    },

    closeShopClick:function(){

        console.log("关闭购物车")
        this.scrollShopScrollView.active=false

    },
    
    start () {

    },
    
    // update (dt) {},
});


